import 'package:lcapp/data/zixun_data_entity.dart';

zixunDataEntityFromJson(ZixunDataEntity data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['title'] != null) {
		data.title = json['title'].toString();
	}
	if (json['quote'] != null) {
		data.quote = json['quote'].toString();
	}
	if (json['content'] != null) {
		data.content = json['content'].toString();
	}
	if (json['origin'] != null) {
		data.origin = json['origin'].toString();
	}
	if (json['images'] != null) {
		data.images = json['images'].toString();
	}
	if (json['createTime'] != null) {
		data.createTime = json['createTime'].toString();
	}
	if (json['isCollection'] != null) {
		data.isCollection = json['isCollection'] is String
				? int.tryParse(json['isCollection'])
				: json['isCollection'].toInt();
	}
	if (json['flag'] != null) {
		data.flag = json['flag'] is String
				? int.tryParse(json['flag'])
				: json['flag'].toInt();
	}
	if (json['layout'] != null) {
		data.layout = json['layout'] is String
				? int.tryParse(json['layout'])
				: json['layout'].toInt();
	}
	if (json['vipFlag'] != null) {
		data.vipFlag = json['vipFlag'] is String
				? int.tryParse(json['vipFlag'])
				: json['vipFlag'].toInt();
	}
	if (json['articleList'] != null) {
		data.articleList = (json['articleList'] as List).map((v) => ZixunDataEntity().fromJson(v)).toList();
	}
	return data;
}

Map<String, dynamic> zixunDataEntityToJson(ZixunDataEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['title'] = entity.title;
	data['quote'] = entity.quote;
	data['content'] = entity.content;
	data['origin'] = entity.origin;
	data['images'] = entity.images;
	data['createTime'] = entity.createTime;
	data['isCollection'] = entity.isCollection;
	data['flag'] = entity.flag;
	data['layout'] = entity.layout;
	data['vipFlag'] = entity.vipFlag;
	data['articleList'] =  entity.articleList?.map((v) => v.toJson())?.toList();
	return data;
}

zixunDataHomeEntityFromJson(ZixunDataHomeEntity data, Map<String, dynamic> json) {
	if (json['createDate'] != null) {
		data.createDate = json['createDate'].toString();
	}
	if (json['articleList'] != null) {
		data.articleList = (json['articleList'] as List).map((v) => ZixunDataEntity().fromJson(v)).toList();
	}
	return data;
}

Map<String, dynamic> zixunDataHomeEntityToJson(ZixunDataHomeEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['createDate'] = entity.createDate;
	data['articleList'] =  entity.articleList?.map((v) => v.toJson())?.toList();
	return data;
}